#include "../terra-ge.h"
#include "vobject.h"
#include "camera.h"
#include <list>
#include "../rsrc/shader_manager.h"
#include "light.h"
#include "../file/errlog.h"

#ifndef TERRAGE_RENDERER_H_INCLUDED
#define TERRAGE_RENDERER_H_INCLUDED

namespace TerraGE {


    const int DEBUG_LIGHTS=1;
    const int DEBUG_HEIGHT=2;
    const int DEBUG_NORMALS=4;
    const int DEBUG_NO_LIGHTING=8;
    const int DEBUG_EDITOR=16;

    class Renderer {
        protected:
            ALLEGRO_DISPLAY *display;
            ALLEGRO_BITMAP *shadow_map;
            ALLEGRO_BITMAP *final_shadow_map;
            float x, y, width, height;
            float aspect_ratio;
            float internal_w, internal_h;
            float zoom;

            Shader_Manager *shader_manager;
        public:
            Renderer(ALLEGRO_DISPLAY *disp, Shader_Manager *sh, float int_w, float int_h,  float w=0, float h=0, float tx=0, float ty=0);

            void Render(Log *log, list<VObject *> *vobjects, list<Light *> *lights, Light *directional_light, Camera *cam, int debug=0);
            void Sort_Z_List(list<VObject *> *vobjects);

            float XtoGX(float v);
            float YtoGY(float v);
            float GXtoX(float v);
            float GYtoY(float v);
            float XtoRX(float v);
            float YtoRY(float v);
            float RXtoX(float v);
            float RYtoY(float v);
            float XtoSX(float v);
            float YtoSX(float v);
    };
}

#endif
